class Test2_For {
    public static void main (String[] args){
//需求：求出1-10之间的数据之和        
        /* int sum = 0;    //定义一个SUM的变量
        for (int i = 1;i <= 10;i++){
            sum = sum + i;
        } 
        System.out.println ("sum = " + sum);*/
//需求:1-100的偶数和
      /*  int sum = 0;
        for (int i = 1 ;i <=100;i++){
            if(i % 2 == 0) {
                sum = sum +i;
            }
        }
        System.out.println("sum = "+sum);*/
//1-100的奇数和
        int sum = 0;
        for (int i = 1;i <= 100;i += 2){
            /*if (i % 2 != 0){
                sum = sum + i;
            }*/
            sum = sum + i;
        }
        System.out.println("sum = "+sum);
    }
}